/*
  SOLID - Interference Detection Library
  Copyright (C) 1997 Gino van den Bergen

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.

  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

  Please send remarks, questions and bug reports to gino@win.tue.nl,
  or write to:
                  Gino van den Bergen
		  Department of Mathematics and Computing Science
		  Eindhoven University of Technology
		  P.O. Box 513, 5600 MB Eindhoven, The Netherlands
*/

#ifndef _TRANSFORM_H_
#define _TRANSFORM_H_

#include <3D/Point.h>
#include <3D/Matrix.h>

class Transform {
public:
  Transform() {}
  Transform(const Point& p, const Quaternion& q) : pos(p), orn(q) {}
  
  void setPosition(const Point& p)         { pos = p; }
  void setOrientation(const Quaternion& q) { orn.setValue(q); }

  void setMatrix(const float *m);
  void setMatrix(const double *m);

  const Point&  getPosition()    const { return pos; }
  const Matrix& getOrientation() const { return orn; }

  Vector operator()(const Vector& v) const {
    return Vector(orn.rowdot(X, v), orn.rowdot(Y, v), orn.rowdot(Z, v));
  }
  
  Point operator()(const Point& p) const {
//            printf("operatore parentesi\n\n\n\");
    return Point(pos[X] + orn.rowdot(X, p), 
		 pos[Y] + orn.rowdot(Y, p), 
		 pos[Z] + orn.rowdot(Z, p));
  }
  
  Transform& operator*=(const Transform& t);

  void setIdentity();
  void setInverse(const Transform& t);
  void setMult(const Transform& t1, const Transform& t2);
  void setInvMult(const Transform& t1, const Transform& t2); 

private:
  Point pos;
  Matrix orn;
};

#endif

